import threading
import time


def task1():
    for i in range(5):
        print("Task 1 is running")
        time.sleep(1)


def task2():
    for i in range(5):
        print("Task 2 is running")
        time.sleep(1)


# 创建两个线程
thread1 = threading.Thread(target=task1)
thread2 = threading.Thread(target=task2)

# 直接调用 run 方法，线程任务在当前线程中执行
thread1.run()
thread2.run()

print("Both tasks are done")
